<template>
  <div>
    <!-- <div class="main_navigator">
      <el-breadcrumb separator="/" style="font-size:18px;">
        <el-breadcrumb-item>
          <span @click="goBack">返回</span>
        </el-breadcrumb-item>
        <el-breadcrumb-item>{{crumbOne}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{crumbTwo}}</el-breadcrumb-item>
        <el-breadcrumb-item>
          <span :class="active_crumb">{{crumbThree}}</span>
        </el-breadcrumb-item>
      </el-breadcrumb>
    </div> -->
    <div class="main_content">
       <el-form id="s_form" :model="searchForm" :inline="true" ref="searchForm">
        <el-form-item prop="searchText">
          <el-input
            style="width:200px;"
            clearable
            v-model="searchForm.searchText"
            placeholder="请输项目/编号查询"
            @keydown.enter.native="doSearch()"
          ></el-input>
          <el-button type="primary" @click="doSearch()" class="added">
            <i class="el-icon-search"></i>
            搜索
          </el-button>
          </el-form-item>
          <el-form-item>
            <el-button v-if="showBack" @click="doReturn()">
              <i class="el-icon-back"></i>
              返回
            </el-button>
          </el-form-item>
        </el-form>
      <!-- <el-table
        :data="tableData"
        border
        style="width: 100%;margin-top:10px;"
        :header-cell-style="tableHeaderStyle"
      >
        <el-table-column prop="name" label="账号" align="center"></el-table-column>
        <el-table-column prop="date" label="用户" align="center"></el-table-column>
        <el-table-column prop="name" label="项目" align="center"></el-table-column>
        <el-table-column prop="date" label="专业" align="center"></el-table-column>
        <el-table-column prop="name" label="角色" align="center"></el-table-column>
        <el-table-column prop="date" label="旁站" align="center"></el-table-column>
        <el-table-column prop="date" label="日期" align="center"></el-table-column>
        <el-table-column label="操作" align="center" width="140">
          <template slot-scope="scope">
            <el-button type="success" size="mini" @click="handleDetail(scope.$switch, scope.row)">详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="page">
        <el-pagination
          small
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          :page-size="thePageSize"
          layout="total, prev, pager, next, jumper"
          :total="myTotal"
        ></el-pagination>
      </div> -->
      <myTable
        style="margin-top:15px"
        auto='getAllList'
        :height='Height-210'
        min-width='130'
        :myColumn=tableProp
        ahide='index,checkbox,mySplitPage,tooltip,background'
        hide="checkbox"
        slots='操作,206,right'
        select='console'
        @header-click='console'
        hook:created=' myTable.tableData = tableData '
      >
        <template slot-scope='button'>
          <el-button v-if='button.scope.row.updateState==1' type="success" size="mini" @click="handleDetail(button.scope.$index, button.scope.row)">
            <i class="el-icon-view"></i>
           修改记录
          </el-button>
          <el-button
            v-if='button.scope.row.updateState==0'
            :disabled='button.scope.row.updateState==0'
            type="info"
            size="mini"
            @click="handleDetail(button.scope.$index, button.scope.row)"
          >
            <i class="el-icon-view"></i>
            修改记录
          </el-button>
          <!-- :style='button.scope.row.updateState===0 && {width: "100%"}'-->
          <el-button type="primary" size="mini" @click="record(button.scope.$index, button.scope.row)">
            <i class="el-icon-bell"></i>
            报警记录
          </el-button>
        </template>
      </myTable>
    </div>
  </div>
</template>
<script>
import myhttp, {
  isEmpty,
  msgError,
  msgSuccess,
  msgWarning
} from "../../utils/myhttp";
import qs from "qs";
import api from "../../utils/api";
export default {
  data() {
    return {
      loading: "",
      active_crumb: "active_crumb", //面包屑当前颜色
      tableHeaderStyle: {
        //表头样式
        "background-color": "rgb(242,242,242)"
      },
      // crumbOne: "一级菜单",
      // crumbTwo: "二级菜单",
      // crumbThree: "三级菜单",
      multipleSelection: [], //多选
      theRow: {}, //当前行数据
      theIndex: 0, //当前下标
      theAdd: {}, //新增数据
      hasMultiDelete: false, //是否多选
      searchForm:{
        searchText: "", //搜索字段
      },
      myTotal: 1, //分页总条数，默认1
      currentPage: 1, //初始化当前页
      nowPage: 1, //当前页
      thePageSize: 15, //每页条数
      tableData: [],
      tableProp: [
        { label: "项目", prop: "projectName",sort: true },
        // { label: "专业", prop: "major" ,html(prop){
        //   if( prop === 1 ) {
        //     return '<span>土建</span>'
        //   } else if( prop === 2 ) {
        //     return '<span>钢结构</span>'
        //   } else if( prop === 3 ) {
        //     return '<span>管道</span>'
        //   } else if( prop === 4 ) {
        //     return '<span>静设备</span>'
        //   }
        // }},
        { label: "旁站", prop: "stationType", sort: true, html(prop) {
          return $.class[prop]||'';
          //  if( prop === 111 ) {
          //   return '<span>混凝土浇筑旁站</span>'
          // } else if( prop === 112 ) {
          //   return '<span>大体积混凝土浇筑旁站</span>'
          // } else if( prop === 113 ) {
          //   return '<span>预应力混凝土张拉旁站</span>'
          // } else if( prop === 114 ) {
          //   return '<span>大型机组二次灌浆旁站</span>'
          // } else if( prop === 115 ) {
          //   return '<span>自定义旁站</span>'
          // }
        } },
        // { label: "角色", prop: "roleId", sort: true, html(prop) {
        //   return prop ===1 ? '<span>系统管理员</span>' : '<span>项目运营员</span>'
        // } },
        // { label: "创建日期", prop: "createTime", sort: true },
        // { label: "开始日期", prop: "startTime", sort: true },
        { label: "编号", prop: "projectName", asort: true },
        { label: "旁站开始时间", prop: "startTime", sort: true ,width:180},
        { label: "旁站结束时间", prop: "endTime", sort: true ,width:180},
        { label: "职位", prop: "projectUserInfoList", html(prop,row){
          return Return(prop,(a,v)=>a+'、'+v.positionName).slice(1);
        } },
        { label: "旁站人", prop: "createPerson", sort: true},
      ],
      alldata:[],
      showBack:false,
    };
  },
  components: {},
  methods: {
    doReturn(){
      this.$refs.searchForm.resetFields()
      this.getAllList();
      this.showBack = false;
    },
    //报警值记录
    record(index,row){
      this.$router.push({
        name:'recordDetails',
        params: {
          stationId: row.stationId,
        }
      });
    },
    handleDetail(index,row) {
      var data = row.projectUserInfoList || [];;
      var str = '';
      for(var i = 0; i < data.length; i++){
        this.alldata = data[i];
        if(data[i].positionType === '1'){
          // this.userName = data[i].userName
          // this.phoneNumber = data[i].phoneNumber
          // str += '、' + data[i].userName + '  ' + data[i].phoneNumber;
          this.user_name = data[i].userName;
        }
      };
      this.$router.push({
        name:"logDetails",
        params: {
          // user_name: this.userName,
          // user_account: this.phoneNumber,
          user_all: this.user_name,
          project_name: row.projectName,
          programme_name: row.programmeName,
          project_number: row.projectNumber,
          stationId: row.stationId,
        },
      });
    },
    doSearch() {
      //搜索方法
      this.getAllList();
      this.showBack = true;
    },
    handleCurrentChange(val) {
      //分页查询
      this.nowPage = val;
      this.getAllList();
    },
    openLoading() {
      //loading请求等待
      this.loading = this.$loading({
        lock: true,
        text: "Loading",
        spinner: "el-icon-loading",
        background: "rgba(0, 0, 0, 0.7)"
      });
    },
    getAllList: async function(pageNum,pageSize) {
     var res = await $.post('getAllStationByuserId',{
        // projectLeaderId:localStorage.getItem("userId"),
        pageNum, //当前页
        pageSize,//每页显示条数
        searchText: this.searchForm.searchText,//搜索文本
        userId:localStorage.getItem("userId"),
      });
      $return('__',res);
      if(!res.success) return $.msgError(res.msg||'error!');
    }
  },
  mounted() {}
};
</script>
<style scoped>

</style>


